//+-----------------------------------------------------
//| Module: fibonacci_number
//| Description: Calculates the N:th fibonachi number
//| 0, 1, 1, 2, 3, 5, 8, 13 etc.
//| Input: n, the order number in the series of the
//| number to calculate
//| Result: The N:th fibonachi number
//| Conditions: The input is small enough for the result
//| to be possible to store as an integer
//+-----------------------------------------------------

#include <iostream>


    int fibonacciCount( int number )
    {
    if ((number == 0) || (number == 1)) // base cases
       return number;
    else
       return fibonacciCount( number - 1 ) + fibonacciCount( number - 2 );
    }

int main (int argc, const char* argv[])
{

	std::cout << "----- Menu Lab2 -----" << std::endl;
    std::cout << "1. Fibonacci number (iterative solution)" << std::endl;
    std::cout << "2. Fibonacci number (recursive solution)" << std::endl;
    std::cout << "3. Multiply two complex numbers" << std::endl;
    std::cout << "4. Pascals triangle (recursive solution)" << std::endl;
    std::cout << "?. Print this menu" << std::endl;
    std::cout << "0. Exit program" << std::endl;
    std::cout << "---------------------" << std::endl;

	int fibonacci = 0;
    char choiseMenu = 0;


    while (choiseMenu != '0') {
           std::cout << "Enter your choice (? gives help): ";
           std::cin >> choiseMenu;
           int numberFibo = 0;
           int firstNumber = 0;
           int nextNumber = 1;
           int currNumber = 0;
        switch (choiseMenu)
        {
        case '1':
            std::cout << "Calculate fibonacci number N iteratively, enter N: ";
    	    std::cin >> numberFibo;

    	    for ( int i = 0; i < numberFibo; ++i){
    	    	 currNumber = firstNumber + nextNumber;
    	    	 nextNumber = firstNumber;
    	    	 firstNumber = currNumber;
    	    }
    	    std::cout << "fibonacci(8) = " << currNumber << std::endl;
    	    break;
    	case '2':
    		std::cout << "Calculate fibonacci number N recursively, enter N:";
    		std::cin >> numberFibo;
    		std::cout << "fibonacci(" << numberFibo << ") = " << fibonacciCount(numberFibo) << std::endl;;
    		break;
    	case '?':
    		std::cout << "----- Menu Lab2 -----" << std::endl;
    	    std::cout << "1. Fibonacci number (iterative solution)" << std::endl;
    	    std::cout << "2. Fibonacci number (recursive solution)" << std::endl;
    	    std::cout << "3. Multiply two complex numbers" << std::endl;
    	    std::cout << "4. Pascals triangle (recursive solution)" << std::endl;
    	    std::cout << "?. Print this menu" << std::endl;
    	    std::cout << "0. Exit program" << std::endl;
    	    std::cout << "---------------------" << std::endl;
    		break;
        }  // switch
    }; // while
    std::cout << "Bye " << std::endl;
} // main
